package com.example.base.plugin.moudel;

import com.alibaba.fastjson.JSONObject;
import com.example.base.app.AppFunction;
import com.example.base.security.domain.SysUserEntity;
import com.example.base.security.service.SysUserService;
import com.example.base.utils.Result;
import com.example.base.utils.SpringContextUtils;

import java.util.Map;

public class SysUserPlugin implements AppFunction {

    @Override
    public String getAppFunctionName() {
        return "getSysUserByUserName";
    }

    @Override
    public Object appFunction(Map<String, Object> objectMap) {
        if(objectMap==null){
            return Result.errorInfo("传的数据不得为空");
        }
        if(!objectMap.containsKey("username")){
            return Result.errorInfo("没有 username信息");
        }
        SysUserService sysUserService= SpringContextUtils.getBean(SysUserService.class);
        SysUserEntity entity=sysUserService.selectUserByName(String.valueOf(objectMap.get("username")));
        entity.setPassword(null);
        return Result.successInfo(entity);
    }
}
